run_python2() {
	python2 python2/easypython2.py
}

run_python3() {
	python3 python3/easypython3.py
}

run_bash() {
	sh ./bash/easybash.sh
}

run_golang() {
	go run golang/easygolang.go
}

run_java() {
	lang=java
	rm -rf temp/$lang
	mkdir -p temp/$lang/classes

	javac -d temp/$lang/classes -encoding utf8 jvm/$lang/ht/*.java
	jar cvf temp/$lang/easyjava.jar -C temp/$lang/classes . >/dev/null
	java -cp temp/$lang/easyjava.jar ht.EasyJava node nodejs/easyjs.js
}

run_scala() {
	lang=scala
	mkdir -p temp/${lang}/classes

	# brew install scala
	scalac -deprecation -d temp/$lang/classes jvm/$lang/ht/*.scala
	jar -cvf temp/$lang/easyscala.jar -C temp/$lang/classes . >/dev/null

	# find /usr/local -name scala-library.jar
	# scala_jar=`find /usr/local -name scala-library.jar|head -n 1`
	scala_jar="/usr/local/Cellar/scala/2.13.1_1/libexec/lib/scala-library.jar"
	java -cp temp/$lang/easyscala.jar:$scala_jar ht.EasyScala
}

run_kotlin() {
	lang=kotlin
	mkdir -p temp/$lang

	# brew install kotlinc
	kotlinc jvm/$lang/ht/easykotlin.kt -include-runtime -d temp/$lang/easykotlin.jar
	java -cp temp/$lang/easykotlin.jar ht.EasykotlinKt
}

run_groovy() {
	# lang=groovy
	# brew install groovy
	# set GROOVY_HOME=/usr/local/opt/groovy/libexec
	groovy jvm/groovy/ht/easygroovy.groovy
}

run_perl() {
	perl perl/easyperl.pl
}

run_clang() {
	lang=clang
	mkdir -p temp/${lang}

	gcc clang/easyclang.c -o temp/${lang}/easyclang
	./temp/${lang}/easyclang
}

run_lua() {
	lua lua/easylua.lua
}

run_nodejs() {
	node nodejs/easyjs.js
}

run_typescript() {
	which tsc || npm install -g typescript
	tsc -v
	# tsc --outFile file.js file.ts
	mkdir -p temp/typescript
	tsc --lib es6,dom --outFile temp/typescript/easytypescript.js typescript/easytypescript.ts
	node temp/typescript/easytypescript.js
}
run_php() {
	php php/easyphp.php
}
run_() {
    echo "WARN:default python2"
    lang="python2"
    run $lang
}

run_all() {
    lans="python2 bash golang java scala kotlin groovy perl clang"
    for lang in $lans; do
        echo "---------$lang----------"
        run $lang
    done
}

run() {
	p=$1
	p="run_$p"
	$p
}

run $@
